function getCookie(name) 
{ 
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
 
    if(arr=document.cookie.match(reg))
 
        return unescape(arr[2]); 
    else 
        return null; 
}

function openUrl(appUrl, isogeny) {
	if (isogeny) {
		window.location.href = appUrl;
	} else {
		var token = getCookie("session-id");
		var data = {token:token};
		$.ajax({
			url : "api/user/getTicket",
			contentType : "application/json",
			data : JSON.stringify(data),
			type : "POST",
			dataType : "json",
			success : function(rst) {
				if (rst.success) {
					var url = appUrl + "?ticket=" + rst.data;
					window.location.href = url;
				} else {
					alert("获取ticket失败:" + rst.msg);
				}
			},
			error : function(rst) {
				alert("获取ticket失败");
			}
		});
	}

}

